package com.pollyduan.springInitializr.controller;

import java.io.File;
import java.nio.file.Files;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pollyduan.springInitializr.Constants;

@Controller
@ResponseBody
public class MetadataController {
	@GetMapping("/project_metadata/spring-boot")
	public synchronized String getMetadata() {
		String projectMetadata = null;
		// 从本地缓存中取数据
		try {
			projectMetadata = new String(Files.readAllBytes(new File(Constants.metadataLocalFile).toPath()));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return projectMetadata;
	}
}
